# 作者：宋安康
# 开发时间：2023/9/3 14:08
from sklearn import datasets
from sklearn.model_selection import train_test_split
from collections import Counter
from sklearn.datasets import load_iris
from sklearn.model_selection import ShuffleSplit

iris = datasets.load_iris()

def test02():
    X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.3)
    #  加载数据集
    X, y = load_iris(return_X_y=True)
    print('原始类别比例:', Counter(y))

    # 随机分割
    spliter = ShuffleSplit(n_splits=1000, test_size=0.3, random_state=0)
    for train, test in spliter.split(X, y):
        print('随机多次分割:', Counter(y[test]))

    print('数据集大小')
    print(iris.data.shape, iris.target.shape)
    print("留出法")
    print(X_train.shape, y_train.shape)
    print(X_test.shape, y_test.shape)

if __name__ == '__main__':
    test02()
import sklearn
print("Sklearn verion is {}".format(sklearn.__version__))








